<!--
 * @Author: hq
 * @Date: 2022-08-18 18:06:34
 * @LastEditors: hq
 * @LastEditTime: 2022-08-18 18:44:34
 * @Description: your project
 * @version: 1.0
-->
<template>
  <div>
    <el-table
      border
      :data="tableData"
      :header-cell-style="{
        'text-align': 'center',
      }"
      :cell-style="{ 'text-align': 'center' }"
      style="width: 100%"
      highlight-current-row
    >
      <el-table-column prop="mch" label="商家id" min-width="15%">
      </el-table-column>
      <el-table-column prop="mch_name" label="商家名称" min-width="20%">
      </el-table-column>
      <el-table-column prop="aid_text" label="区域" min-width="20%">
      </el-table-column>
      <el-table-column label="操作" min-width="30%">
        <template slot-scope="scope">
          <div class="caozuo">
            <div class="handleDelete hand_cs" @click="handleDelete(scope.row)">
              删除
            </div>
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { agentDetail, agentDetailDel } from "@/api/merchant";
export default {
  props: ["rowData"],
  data() {
    return {
      tableData: [],
    };
  },
  methods: {
    async agentDetail() {
      const { data, err } = await agentDetail({
        mch: this.rowData.mch,
      });
      if (err === 0) {
        this.tableData = data;
      }
    },
    async agentDetailDel(id) {
      const { msg, err } = await agentDetailDel({
        id,
      });
      if (err === 0) {
        this.$message({
          showClose: true,
          message: "操作成功",
          type: "success",
        });
        this.agentDetail();
        this.$emit("handleCloseDetail");
      } else {
        this.$message({
          showClose: true,
          message: msg,
          type: "error",
        });
      }
    },
    //删除
    handleDelete(row) {
      this.$confirm("是否确认删除?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.agentDetailDel(row.id);
        })
        .catch(() => {});
    },
  },
  created() {
    this.agentDetail();
  },
};
</script>

<style lang="scss" scoped></style>
